import Vue from 'vue'
import VueRouter from 'vue-router'
import cartRouter from './modules/gouwu'
import classifyRouter from './modules/classify'
import dissertationRouter from './modules/dissertation'
import homeRouter from './modules/home'
import mineRouter from './modules/mine'
// import channelRouter from './modules/channel'
// import detailsRouter from './modules/details'
Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    redirect:'/home',
  },
  
  ...classifyRouter,
  ...dissertationRouter,
  ...homeRouter,
  ...mineRouter,
  ...cartRouter,
//   ...channelRouter,
//   ...detailsRouter,
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
 
 
 
// replace
// const originalReplace = VueRouter.prototype.replace
// VueRouter.prototype.replace= function replace(location) {
//   return originalReplace.call(this, location).catch(err => err)
// }
// router.beforeEach((to,from,next)=>{
//   if(to.meta.needLogin){
//     const token = localStorage.getItem("token")
//     if(token){
//       next()
//     }else{
//       Vue.prototype.$toast('请先登录');
//       next({
//         path:"/Skit",
//         query:{
//           goto:to.fullPath
//         }
//       })
      
//       // 定时器
//     }
//   }else{
//     next()
//   }
// })

export default router